<!DOCTYPE html>
<html lang="zh_CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="generator" content="VuePress 2.0.0-beta.45">
    <style>
      :root {
        --c-bg: #fff;
      }
      html.dark {
        --c-bg: #22272e;
      }
      html, body {
        background-color: var(--c-bg);
      }
    </style>
    <script>
      const userMode = localStorage.getItem('vuepress-color-scheme');
			const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
			if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
				document.documentElement.classList.toggle('dark', true);
			}
    </script>
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"><title>Generating Bash Completions For Your Own cobra.Command | 科科人神</title><meta name="description" content="科科人神，后端软件工程师，喜欢云原生">
    <link rel="modulepreload" href="/assets/app.80e5dc69.js"><link rel="modulepreload" href="/assets/bash_completions.html.31fa6426.js"><link rel="modulepreload" href="/assets/bash_completions.html.ed68147e.js"><link rel="prefetch" href="/assets/index.html.cba988ab.js"><link rel="prefetch" href="/assets/1.html.8ac90e92.js"><link rel="prefetch" href="/assets/19.html.4444be95.js"><link rel="prefetch" href="/assets/必备知识.html.7da85c42.js"><link rel="prefetch" href="/assets/必备知识罗列.html.5e18db77.js"><link rel="prefetch" href="/assets/1.html.356f0755.js"><link rel="prefetch" href="/assets/2.html.085440fc.js"><link rel="prefetch" href="/assets/3.html.09effb5c.js"><link rel="prefetch" href="/assets/1.html.50fb5135.js"><link rel="prefetch" href="/assets/1.html.17222973.js"><link rel="prefetch" href="/assets/1.html.0a197ef1.js"><link rel="prefetch" href="/assets/4-1.html.073fbd99.js"><link rel="prefetch" href="/assets/4-2.html.64039343.js"><link rel="prefetch" href="/assets/4.html.021c0881.js"><link rel="prefetch" href="/assets/5-6-1.html.34978ed1.js"><link rel="prefetch" href="/assets/5-6-2.html.f004f560.js"><link rel="prefetch" href="/assets/5-6.html.f5ad3835.js"><link rel="prefetch" href="/assets/index.html.467e6eba.js"><link rel="prefetch" href="/assets/index.html.f3622043.js"><link rel="prefetch" href="/assets/index.html.a2792a89.js"><link rel="prefetch" href="/assets/index.html.5d63961d.js"><link rel="prefetch" href="/assets/index.html.0b5fc023.js"><link rel="prefetch" href="/assets/index.html.2f735cf1.js"><link rel="prefetch" href="/assets/index.html.9d71a6d6.js"><link rel="prefetch" href="/assets/man_docs.html.2f0dd0c9.js"><link rel="prefetch" href="/assets/md_docs.html.20de452a.js"><link rel="prefetch" href="/assets/rest_docs.html.b77e8a2e.js"><link rel="prefetch" href="/assets/zsh_completions.html.60976ab2.js"><link rel="prefetch" href="/assets/syslog.html.48554683.js"><link rel="prefetch" href="/assets/daily_dep.html.2f155f5c.js"><link rel="prefetch" href="/assets/getting_started.html.769a2eaa.js"><link rel="prefetch" href="/assets/installation.html.e6b0002b.js"><link rel="prefetch" href="/assets/migrating.html.128871c1.js"><link rel="prefetch" href="/assets/new_project.html.8326d390.js"><link rel="prefetch" href="/assets/uninstalling.html.26650652.js"><link rel="prefetch" href="/assets/deduction.html.d4acd3fa.js"><link rel="prefetch" href="/assets/ensure_mechanics.html.603c62de.js"><link rel="prefetch" href="/assets/404.html.a15b4cbd.js"><link rel="prefetch" href="/assets/index.html.29aac47c.js"><link rel="prefetch" href="/assets/index.html.b64fbb23.js"><link rel="prefetch" href="/assets/index.html.cd48e230.js"><link rel="prefetch" href="/assets/index.html.6b048e76.js"><link rel="prefetch" href="/assets/index.html.7f0a6e54.js"><link rel="prefetch" href="/assets/index.html.b5a71586.js"><link rel="prefetch" href="/assets/index.html.60805430.js"><link rel="prefetch" href="/assets/index.html.60736b0b.js"><link rel="prefetch" href="/assets/index.html.80dddd6d.js"><link rel="prefetch" href="/assets/index.html.cc3c6a0d.js"><link rel="prefetch" href="/assets/index.html.44e62fda.js"><link rel="prefetch" href="/assets/index.html.015a0b2c.js"><link rel="prefetch" href="/assets/index.html.415d4517.js"><link rel="prefetch" href="/assets/index.html.d1d65e23.js"><link rel="prefetch" href="/assets/index.html.725ac526.js"><link rel="prefetch" href="/assets/index.html.c824ee30.js"><link rel="prefetch" href="/assets/1.html.4fb25663.js"><link rel="prefetch" href="/assets/19.html.ded8a9c9.js"><link rel="prefetch" href="/assets/必备知识.html.0ff3a77d.js"><link rel="prefetch" href="/assets/必备知识罗列.html.85e0f635.js"><link rel="prefetch" href="/assets/1.html.4f76037b.js"><link rel="prefetch" href="/assets/2.html.05a6e91e.js"><link rel="prefetch" href="/assets/3.html.30d4c4b6.js"><link rel="prefetch" href="/assets/1.html.ce86a757.js"><link rel="prefetch" href="/assets/1.html.0f8a9434.js"><link rel="prefetch" href="/assets/1.html.f4ee2fe7.js"><link rel="prefetch" href="/assets/4-1.html.c7cc75b6.js"><link rel="prefetch" href="/assets/4-2.html.36807608.js"><link rel="prefetch" href="/assets/4.html.c03ae622.js"><link rel="prefetch" href="/assets/5-6-1.html.651e5517.js"><link rel="prefetch" href="/assets/5-6-2.html.5ccfdb5e.js"><link rel="prefetch" href="/assets/5-6.html.882bc951.js"><link rel="prefetch" href="/assets/index.html.9d9ba895.js"><link rel="prefetch" href="/assets/index.html.3da373d1.js"><link rel="prefetch" href="/assets/index.html.6ec0b380.js"><link rel="prefetch" href="/assets/index.html.f8c39be7.js"><link rel="prefetch" href="/assets/index.html.e8d4dc57.js"><link rel="prefetch" href="/assets/index.html.2275c56f.js"><link rel="prefetch" href="/assets/index.html.711c721b.js"><link rel="prefetch" href="/assets/man_docs.html.cc0f68c6.js"><link rel="prefetch" href="/assets/md_docs.html.dd10674f.js"><link rel="prefetch" href="/assets/rest_docs.html.46da86e5.js"><link rel="prefetch" href="/assets/zsh_completions.html.64d57b81.js"><link rel="prefetch" href="/assets/syslog.html.5324d692.js"><link rel="prefetch" href="/assets/daily_dep.html.b7a8b70b.js"><link rel="prefetch" href="/assets/getting_started.html.29c6534a.js"><link rel="prefetch" href="/assets/installation.html.b11da95a.js"><link rel="prefetch" href="/assets/migrating.html.92825adc.js"><link rel="prefetch" href="/assets/new_project.html.8fcfe511.js"><link rel="prefetch" href="/assets/uninstalling.html.34c1a6fb.js"><link rel="prefetch" href="/assets/deduction.html.2f0a618b.js"><link rel="prefetch" href="/assets/ensure_mechanics.html.7818d8b5.js"><link rel="prefetch" href="/assets/404.html.37719150.js"><link rel="prefetch" href="/assets/index.html.bc2fbcdd.js"><link rel="prefetch" href="/assets/index.html.2363e42b.js"><link rel="prefetch" href="/assets/index.html.691f6b43.js"><link rel="prefetch" href="/assets/index.html.c73599f4.js"><link rel="prefetch" href="/assets/index.html.32559aa6.js"><link rel="prefetch" href="/assets/index.html.283a60cc.js"><link rel="prefetch" href="/assets/index.html.b72bddc9.js"><link rel="prefetch" href="/assets/index.html.aebed871.js"><link rel="prefetch" href="/assets/index.html.1bace120.js"><link rel="prefetch" href="/assets/index.html.7913d44a.js"><link rel="prefetch" href="/assets/index.html.4e5360d4.js"><link rel="prefetch" href="/assets/index.html.028748b8.js"><link rel="prefetch" href="/assets/index.html.e9cb3a86.js"><link rel="prefetch" href="/assets/index.html.e31e8159.js"><link rel="prefetch" href="/assets/index.html.01049197.js"><link rel="prefetch" href="/assets/404.30cc8863.js"><link rel="prefetch" href="/assets/HomePage.4e823a0b.js"><link rel="prefetch" href="/assets/Layout.61f5e0fd.js"><link rel="prefetch" href="/assets/Links.8680cda6.js"><link rel="prefetch" href="/assets/Post.93b09438.js"><link rel="prefetch" href="/assets/Tags.3d9bb337.js">
    <link rel="stylesheet" href="/assets/style.8b24233a.css">
  </head>
  <body>
    <div id="app"><!--[--><div class="theme-container"><!--[--><header class="navbar is-fixed is-visible invert"><span><a href="/" class=""><span class="site-name">$ cd /home/</span></a></span><div class="navbar-items-wrapper" style=""><!--[--><!--]--><nav class="navbar-items can-hide"><!--[--><div class="navbar-item"><a href="/" class="" aria-label="home"><!--[--><!--]--><span class="nav-icon"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="0 0 20 20" fill="currentColor"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"/></svg></span><span>home</span><!--[--><!--]--></a></div><div class="navbar-item"><a href="/tags/" class="" aria-label="归档"><!--[--><!--]--><span class="nav-icon"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="-1.6 -1.6 19.2 19.2" fill="currentColor"><path d="M2 2a1 1 0 011-1h4.586a1 1 0 01.707.293l7 7a1 1 0 010 1.414l-4.586 4.586a1 1 0 01-1.414 0l-7-7A1 1 0 012 6.586V2zm3.5 4a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"/><path d="M1.293 7.793A1 1 0 011 7.086V2a1 1 0 00-1 1v4.586a1 1 0 00.293.707l7 7a1 1 0 001.414 0l.043-.043-7.457-7.457z"/></svg></span><span>归档</span><!--[--><!--]--></a></div><div class="navbar-item"><a href="/links/" class="" aria-label="作品合集"><!--[--><!--]--><span class="nav-icon"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="-79.52 -43.52 599.04 599.04" fill="currentColor"><path d="M382.7 292.5l2.7 2.7-170-167.3c-3.5-3.5-9.7-3.7-13.8-.5L144.3 171c-4.2 3.2-4.6 8.7-1.1 12.2l68.1 64.3c3.6 3.5 9.9 3.7 14 .5l.1-.1c4.1-3.2 10.4-3 14 .5l84 81.3c3.6 3.5 3.2 9-.9 12.2l-93.2 74c-4.2 3.3-10.5 3.1-14.2-.4L63.2 268c-3.5-3.5-9.7-3.7-13.9-.5L3.5 302.4c-4.2 3.2-4.7 8.7-1.2 12.2L211 510.7s7.4 6.8 17.3-.8l198-163.9c4-3.2 4.4-8.7.7-12.2zm54.5-83.4L226.7 2.5c-1.5-1.2-8-5.5-16.3 1.1L3.6 165.7c-4.2 3.2-4.8 8.7-1.2 12.2l42.3 41.7 171.7 165.1c3.7 3.5 10.1 3.7 14.3.4l50.2-38.8-.3-.3 7.7-6c4.2-3.2 4.6-8.7.9-12.2l-57.1-54.4c-3.6-3.5-10-3.7-14.2-.5l-.1.1c-4.2 3.2-10.5 3.1-14.2-.4L109 180.8c-3.6-3.5-3.1-8.9 1.1-12.2l92.2-71.5c4.1-3.2 10.3-3 13.9.5l160.4 159c3.7 3.5 10 3.7 14.1.5l45.8-35.8c4.1-3.2 4.4-8.7.7-12.2z"/></svg></span><span>作品合集</span><!--[--><!--]--></a></div><!--]--><div class="navbar-item"><a style="cursor:pointer;"><span class="nav-icon"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="0 0 24 24" fill="currentColor"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 2c4.968 0 9 4.032 9 9s-4.032 9-9 9-9-4.032-9-9 4.032-9 9-9zm0 16c3.867 0 7-3.133 7-7 0-3.868-3.133-7-7-7-3.868 0-7 3.132-7 7 0 3.867 3.132 7 7 7zm8.485.071l2.829 2.828-1.415 1.415-2.828-2.829 1.414-1.414z"/></svg></span><span>搜索</span></a></div></nav><!--[--><!--]--><!----></div></header><!--]--><div class="sidebar-mask"></div><!--[--><aside class="sidebar"><nav class="navbar-items"><!--[--><div class="navbar-item"><a href="/" class="" aria-label="home"><!--[--><!--]--><span class="nav-icon"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="0 0 20 20" fill="currentColor"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"/></svg></span><span>home</span><!--[--><!--]--></a></div><div class="navbar-item"><a href="/tags/" class="" aria-label="归档"><!--[--><!--]--><span class="nav-icon"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="-1.6 -1.6 19.2 19.2" fill="currentColor"><path d="M2 2a1 1 0 011-1h4.586a1 1 0 01.707.293l7 7a1 1 0 010 1.414l-4.586 4.586a1 1 0 01-1.414 0l-7-7A1 1 0 012 6.586V2zm3.5 4a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"/><path d="M1.293 7.793A1 1 0 011 7.086V2a1 1 0 00-1 1v4.586a1 1 0 00.293.707l7 7a1 1 0 001.414 0l.043-.043-7.457-7.457z"/></svg></span><span>归档</span><!--[--><!--]--></a></div><div class="navbar-item"><a href="/links/" class="" aria-label="作品合集"><!--[--><!--]--><span class="nav-icon"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="-79.52 -43.52 599.04 599.04" fill="currentColor"><path d="M382.7 292.5l2.7 2.7-170-167.3c-3.5-3.5-9.7-3.7-13.8-.5L144.3 171c-4.2 3.2-4.6 8.7-1.1 12.2l68.1 64.3c3.6 3.5 9.9 3.7 14 .5l.1-.1c4.1-3.2 10.4-3 14 .5l84 81.3c3.6 3.5 3.2 9-.9 12.2l-93.2 74c-4.2 3.3-10.5 3.1-14.2-.4L63.2 268c-3.5-3.5-9.7-3.7-13.9-.5L3.5 302.4c-4.2 3.2-4.7 8.7-1.2 12.2L211 510.7s7.4 6.8 17.3-.8l198-163.9c4-3.2 4.4-8.7.7-12.2zm54.5-83.4L226.7 2.5c-1.5-1.2-8-5.5-16.3 1.1L3.6 165.7c-4.2 3.2-4.8 8.7-1.2 12.2l42.3 41.7 171.7 165.1c3.7 3.5 10.1 3.7 14.3.4l50.2-38.8-.3-.3 7.7-6c4.2-3.2 4.6-8.7.9-12.2l-57.1-54.4c-3.6-3.5-10-3.7-14.2-.5l-.1.1c-4.2 3.2-10.5 3.1-14.2-.4L109 180.8c-3.6-3.5-3.1-8.9 1.1-12.2l92.2-71.5c4.1-3.2 10.3-3 13.9.5l160.4 159c3.7 3.5 10 3.7 14.1.5l45.8-35.8c4.1-3.2 4.4-8.7.7-12.2z"/></svg></span><span>作品合集</span><!--[--><!--]--></a></div><!--]--><div class="navbar-item"><a style="cursor:pointer;"><span class="nav-icon"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="0 0 24 24" fill="currentColor"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 2c4.968 0 9 4.032 9 9s-4.032 9-9 9-9-4.032-9-9 4.032-9 9-9zm0 16c3.867 0 7-3.133 7-7 0-3.868-3.133-7-7-7-3.868 0-7 3.132-7 7 0 3.867 3.132 7 7 7zm8.485.071l2.829 2.828-1.415 1.415-2.828-2.829 1.414-1.414z"/></svg></span><span>搜索</span></a></div></nav><!--[--><!--]--><ul class="sidebar-items"><!--[--><li><p tabindex="0" class="sidebar-item sidebar-heading">Generating Bash Completions For Your Own cobra.Command <!----></p><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/posts/2023/4/docs/Cobra/docs/bash_completions.html#example-from-kubectl" class="router-link-active router-link-exact-active sidebar-item" aria-label="Example from kubectl"><!--[--><!--]--><!----><span>Example from kubectl</span><!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/posts/2023/4/docs/Cobra/docs/bash_completions.html#creating-your-own-custom-functions" class="router-link-active router-link-exact-active sidebar-item" aria-label="Creating your own custom functions"><!--[--><!--]--><!----><span>Creating your own custom functions</span><!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/posts/2023/4/docs/Cobra/docs/bash_completions.html#have-the-completions-code-complete-your-nouns" class="router-link-active router-link-exact-active sidebar-item" aria-label="Have the completions code complete your &#39;nouns&#39;"><!--[--><!--]--><!----><span>Have the completions code complete your &#39;nouns&#39;</span><!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/posts/2023/4/docs/Cobra/docs/bash_completions.html#plural-form-and-shortcuts-for-nouns" class="router-link-active router-link-exact-active sidebar-item" aria-label="Plural form and shortcuts for nouns"><!--[--><!--]--><!----><span>Plural form and shortcuts for nouns</span><!--[--><!--]--></a><!----></li><!--]--></ul></li><li><a aria-current="page" href="/posts/2023/4/docs/Cobra/docs/bash_completions.html#specify-valid-filename-extensions-for-flags-that-take-a-filename" class="router-link-active router-link-exact-active sidebar-item" aria-label="Specify valid filename extensions for flags that take a filename"><!--[--><!--]--><!----><span>Specify valid filename extensions for flags that take a filename</span><!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/posts/2023/4/docs/Cobra/docs/bash_completions.html#specify-custom-flag-completion" class="router-link-active router-link-exact-active sidebar-item" aria-label="Specify custom flag completion"><!--[--><!--]--><!----><span>Specify custom flag completion</span><!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/posts/2023/4/docs/Cobra/docs/bash_completions.html#using-bash-aliases-for-commands" class="router-link-active router-link-exact-active sidebar-item" aria-label="Using bash aliases for commands"><!--[--><!--]--><!----><span>Using bash aliases for commands</span><!--[--><!--]--></a><!----></li><!--]--></ul></li><!--]--></ul><!--[--><!--]--></aside><!--]--><div class="page-content"><!--[--><main class="page"><!--[--><div class="article-header" style=""><!----><div class="article-header-content"><!----><h1 class="article-title"></h1><!----><div class="article-icons"><div class="article-icon"><svg class="ov-icon" style="font-size:1.08em;" aria-hidden="true" width="17.28" height="17.28" viewbox="-75.52 -43.52 599.04 599.04" fill="currentColor"><path d="M313.6 304c-28.7 0-42.5 16-89.6 16-47.1 0-60.8-16-89.6-16C60.2 304 0 364.2 0 438.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-25.6c0-74.2-60.2-134.4-134.4-134.4zM400 464H48v-25.6c0-47.6 38.8-86.4 86.4-86.4 14.6 0 38.3 16 89.6 16 51.7 0 74.9-16 89.6-16 47.6 0 86.4 38.8 86.4 86.4V464zM224 288c79.5 0 144-64.5 144-144S303.5 0 224 0 80 64.5 80 144s64.5 144 144 144zm0-240c52.9 0 96 43.1 96 96s-43.1 96-96 96-96-43.1-96-96 43.1-96 96-96z"/></svg><span>科科人神</span></div><!----><div class="article-icon"><svg class="ov-icon" style="font-size:1.08em;" aria-hidden="true" width="17.28" height="17.28" viewbox="0 0 24 24" fill="currentColor"><path fill="none" d="M0 0h24v24H0z"/><path d="M17.618 5.968l1.453-1.453 1.414 1.414-1.453 1.453a9 9 0 11-1.414-1.414zM12 20a7 7 0 100-14 7 7 0 000 14zM11 8h2v6h-2V8zM8 1h8v2H8V1z"/></svg><span>6 min</span></div></div></div><!----></div><!--[--><!--]--><!--]--><div class="theme-gungnir-content"><!--[--><!--]--><!--[--><h1 id="generating-bash-completions-for-your-own-cobra-command" tabindex="-1"><a class="header-anchor" href="#generating-bash-completions-for-your-own-cobra-command" aria-hidden="true">#</a> Generating Bash Completions For Your Own cobra.Command</h1><p>如果你正在使用 generator，可以通过运行下面的命令来创建补全命名：</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>cobra <span class="token function">add</span> completion
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>更新帮助文本，显示 linux 如何安装 bash completion， 查看这里 <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion" target="_blank" rel="noopener noreferrer">Kubectl docs show mac options</a>。</p><div class="language-go ext-go line-numbers-mode"><pre class="language-go"><code><span class="token comment">// completionCmd represents the completion command</span>
<span class="token keyword">var</span> completionCmd <span class="token operator">=</span> <span class="token operator">&amp;</span>cobra<span class="token punctuation">.</span>Command<span class="token punctuation">{</span>
	Use<span class="token punctuation">:</span>   <span class="token string">&quot;completion&quot;</span><span class="token punctuation">,</span>
	Short<span class="token punctuation">:</span> <span class="token string">&quot;Generates bash completion scripts&quot;</span><span class="token punctuation">,</span>
	Long<span class="token punctuation">:</span> <span class="token string">`To load completion run

. &lt;(bitbucket completion)

To configure your bash shell to load completions for each session add to your bashrc

# ~/.bashrc or ~/.profile
. &lt;(bitbucket completion)
`</span><span class="token punctuation">,</span>
	Run<span class="token punctuation">:</span> <span class="token keyword">func</span><span class="token punctuation">(</span>cmd <span class="token operator">*</span>cobra<span class="token punctuation">.</span>Command<span class="token punctuation">,</span> args <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">string</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		rootCmd<span class="token punctuation">.</span><span class="token function">GenBashCompletion</span><span class="token punctuation">(</span>os<span class="token punctuation">.</span>Stdout<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>注意: cobra generator 可能包含打印到 stdout 的消息，例如，如果加载了配置文件，这将破坏自动补全脚本</p><h2 id="example-from-kubectl" tabindex="-1"><a class="header-anchor" href="#example-from-kubectl" aria-hidden="true">#</a> Example from kubectl</h2><p>从一个 cobra 命令生成 bash completion 非常简单。kubernetes kubectl 二进制文件的实际程序如下:</p><div class="language-go ext-go line-numbers-mode"><pre class="language-go"><code><span class="token keyword">package</span> main

<span class="token keyword">import</span> <span class="token punctuation">(</span>
	<span class="token string">&quot;io/ioutil&quot;</span>
	<span class="token string">&quot;os&quot;</span>

	<span class="token string">&quot;k8s.io/kubernetes/pkg/kubectl/cmd&quot;</span>
	<span class="token string">&quot;k8s.io/kubernetes/pkg/kubectl/cmd/util&quot;</span>
<span class="token punctuation">)</span>

<span class="token keyword">func</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	kubectl <span class="token operator">:=</span> cmd<span class="token punctuation">.</span><span class="token function">NewKubectlCommand</span><span class="token punctuation">(</span>util<span class="token punctuation">.</span><span class="token function">NewFactory</span><span class="token punctuation">(</span><span class="token boolean">nil</span><span class="token punctuation">)</span><span class="token punctuation">,</span> os<span class="token punctuation">.</span>Stdin<span class="token punctuation">,</span> ioutil<span class="token punctuation">.</span>Discard<span class="token punctuation">,</span> ioutil<span class="token punctuation">.</span>Discard<span class="token punctuation">)</span>
	kubectl<span class="token punctuation">.</span><span class="token function">GenBashCompletionFile</span><span class="token punctuation">(</span><span class="token string">&quot;out.sh&quot;</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><code>out.sh</code> 会补全子命令和标志。按<a href="https://debian-administration.org/article/316/An_introduction_to_bash_completion_part_1" target="_blank" rel="noopener noreferrer">此处</a>描述， 将它复制到 <code>/etc/bash_completion.d/</code>，并重置你的 terminal。如果在代码中添加额外的注释，可以获得更加智能和灵活的行为。</p><h2 id="creating-your-own-custom-functions" tabindex="-1"><a class="header-anchor" href="#creating-your-own-custom-functions" aria-hidden="true">#</a> Creating your own custom functions</h2><p>一些在 kubernetes 中的实际代码：</p><div class="language-go ext-go line-numbers-mode"><pre class="language-go"><code><span class="token keyword">const</span> <span class="token punctuation">(</span>
        bash_completion_func <span class="token operator">=</span> <span class="token string">`__kubectl_parse_get()
{
    local kubectl_output out
    if kubectl_output=$(kubectl get --no-headers &quot;$1&quot; 2&gt;/dev/null); then
        out=($(echo &quot;${kubectl_output}&quot; | awk &#39;{print $1}&#39;))
        COMPREPLY=( $( compgen -W &quot;${out[*]}&quot; -- &quot;$cur&quot; ) )
    fi
}

__kubectl_get_resource()
{
    if [[ ${#nouns[@]} -eq 0 ]]; then
        return 1
    fi
    __kubectl_parse_get ${nouns[${#nouns[@]} -1]}
    if [[ $? -eq 0 ]]; then
        return 0
    fi
}

__kubectl_custom_func() {
    case ${last_command} in
        kubectl_get | kubectl_describe | kubectl_delete | kubectl_stop)
            __kubectl_get_resource
            return
            ;;
        *)
            ;;
    esac
}
`</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>然后我在命令定义中设置:</p><div class="language-go ext-go line-numbers-mode"><pre class="language-go"><code>cmds <span class="token operator">:=</span> <span class="token operator">&amp;</span>cobra<span class="token punctuation">.</span>Command<span class="token punctuation">{</span>
	Use<span class="token punctuation">:</span>   <span class="token string">&quot;kubectl&quot;</span><span class="token punctuation">,</span>
	Short<span class="token punctuation">:</span> <span class="token string">&quot;kubectl controls the Kubernetes cluster manager&quot;</span><span class="token punctuation">,</span>
	Long<span class="token punctuation">:</span> <span class="token string">`kubectl controls the Kubernetes cluster manager.

Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`</span><span class="token punctuation">,</span>
	Run<span class="token punctuation">:</span> runHelp<span class="token punctuation">,</span>
	BashCompletionFunction<span class="token punctuation">:</span> bash_completion_func<span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><code>BashCompletionFunction</code> 选项实际上只在根命令上有效/有用。执行上述操作将导致在内置处理器无法找到解决方案 时调用 <code>__kubectl_custom_func()</code> (<code>__&lt;command-use&gt;_custom_func()</code>)。在 kubernetes 中，一个有效的命令可能 类似于 <code>kubectl get pod [mypod]</code>。如果你键入 <code>kubectl get pod [tab][tab]</code>，<code>__kubectl_custom_func()</code> 将运行， 因为 <code>cobra.Command</code> 只理解 <code>kubectl</code> 和 <code>get</code>。<code>__kubectl_custom_func()</code> 会看到 <code>cobra.Command</code> 是 <code>kubectl get</code>， 因此将调用另一个 helper <code>__kubectl_get_resource()</code>。<code>__kubectl_get_resource</code> 会看到所收集的 &quot;nouns&quot;。 在我们的例子中，唯一的名词是 <code>pod</code>。所以它会调用 <code>__kubectl_parse_get pod</code>。<code>__kubectl_parse_get</code> 会 call kubernetes 并 得到 <code>pod</code>。然后它将设置 <code>COMPREPLY</code> 为有效的 pods!</p><h3 id="have-the-completions-code-complete-your-nouns" tabindex="-1"><a class="header-anchor" href="#have-the-completions-code-complete-your-nouns" aria-hidden="true">#</a> Have the completions code complete your &#39;nouns&#39;</h3><p>在上面的示例中，假定 &quot;pod&quot; 已经被键入。但是，如果你希望 <code>kubectl get [tab][tab]</code> 显示有效的 &quot;nouns&quot; 列表，则必须设置它们。 <code>kubectl get</code> 的简化代码如下:</p><div class="language-go ext-go line-numbers-mode"><pre class="language-go"><code>validArgs <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">string</span> <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">&quot;pod&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;node&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;service&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;replicationcontroller&quot;</span> <span class="token punctuation">}</span>

cmd <span class="token operator">:=</span> <span class="token operator">&amp;</span>cobra<span class="token punctuation">.</span>Command<span class="token punctuation">{</span>
	Use<span class="token punctuation">:</span>     <span class="token string">&quot;get [(-o|--output=)json|yaml|template|...] (RESOURCE [NAME] | RESOURCE/NAME ...)&quot;</span><span class="token punctuation">,</span>
	Short<span class="token punctuation">:</span>   <span class="token string">&quot;Display one or many resources&quot;</span><span class="token punctuation">,</span>
	Long<span class="token punctuation">:</span>    get_long<span class="token punctuation">,</span>
	Example<span class="token punctuation">:</span> get_example<span class="token punctuation">,</span>
	Run<span class="token punctuation">:</span> <span class="token keyword">func</span><span class="token punctuation">(</span>cmd <span class="token operator">*</span>cobra<span class="token punctuation">.</span>Command<span class="token punctuation">,</span> args <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">string</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		err <span class="token operator">:=</span> <span class="token function">RunGet</span><span class="token punctuation">(</span>f<span class="token punctuation">,</span> out<span class="token punctuation">,</span> cmd<span class="token punctuation">,</span> args<span class="token punctuation">)</span>
		util<span class="token punctuation">.</span><span class="token function">CheckErr</span><span class="token punctuation">(</span>err<span class="token punctuation">)</span>
	<span class="token punctuation">}</span><span class="token punctuation">,</span>
	ValidArgs<span class="token punctuation">:</span> validArgs<span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>注意，我们将 <code>ValidArgs</code> 放在 <code>get</code> 子命令上。这样做会得到如下结果：</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># kubectl get [tab][tab]</span>
<span class="token function">node</span>                 pod                    replicationcontroller  <span class="token function">service</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="plural-form-and-shortcuts-for-nouns" tabindex="-1"><a class="header-anchor" href="#plural-form-and-shortcuts-for-nouns" aria-hidden="true">#</a> Plural form and shortcuts for nouns</h3><p>如果你的名词有很多别名，你可以在 <code>ValidArgs</code> 旁边使用 <code>ArgAliases</code> 来定义它们:</p><div class="language-go ext-go line-numbers-mode"><pre class="language-go"><code>argAliases <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">string</span> <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">&quot;pods&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;nodes&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;services&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;svc&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;replicationcontrollers&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;rc&quot;</span> <span class="token punctuation">}</span>

cmd <span class="token operator">:=</span> <span class="token operator">&amp;</span>cobra<span class="token punctuation">.</span>Command<span class="token punctuation">{</span>
    <span class="token operator">...</span>
	ValidArgs<span class="token punctuation">:</span>  validArgs<span class="token punctuation">,</span>
	ArgAliases<span class="token punctuation">:</span> argAliases
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这些别名在 tab 补全中不会显示给用户，但是如果手工输入，补全算法会将它们作为有效名词接受，例如：</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># kubectl get rc [tab][tab]</span>
backend        frontend       database
`<span class="token variable"><span class="token variable">`</span>

<span class="token comment">### Mark flags as required</span>
大多数情况下，补全只显示子命令。但是，如果要使一个子命令工作，有一个 flag 是必须的，你可能希望它在用户键入 <span class="token variable">`</span></span><span class="token punctuation">[</span>tab<span class="token punctuation">]</span><span class="token punctuation">[</span>tab<span class="token punctuation">]</span><span class="token variable"><span class="token variable">`</span> 时显示出来。
将 flag 标记为 <span class="token variable">`</span></span>Required<span class="token variable"><span class="token variable">`</span>。
<span class="token variable">`</span></span>``go
cmd.MarkFlagRequired<span class="token punctuation">(</span><span class="token string">&quot;pod&quot;</span><span class="token punctuation">)</span>
cmd.MarkFlagRequired<span class="token punctuation">(</span><span class="token string">&quot;container&quot;</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这样做会得到如下结果：</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># kubectl exec [tab][tab][tab]</span>
-c            --container<span class="token operator">=</span>  -p            --pod<span class="token operator">=</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="specify-valid-filename-extensions-for-flags-that-take-a-filename" tabindex="-1"><a class="header-anchor" href="#specify-valid-filename-extensions-for-flags-that-take-a-filename" aria-hidden="true">#</a> Specify valid filename extensions for flags that take a filename</h2><p>在本例中，我们使用 <code>--filename=</code> 并期望得到一个 json 或 yaml 文件作为参数。 为了使这更容易，我们使用有效的文件名扩展名来注释 <code>--filename</code> 标志。</p><div class="language-go ext-go line-numbers-mode"><pre class="language-go"><code>annotations <span class="token operator">:=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">string</span><span class="token punctuation">{</span><span class="token string">&quot;json&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;yaml&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;yml&quot;</span><span class="token punctuation">}</span>
annotation <span class="token operator">:=</span> <span class="token function">make</span><span class="token punctuation">(</span><span class="token keyword">map</span><span class="token punctuation">[</span><span class="token builtin">string</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">string</span><span class="token punctuation">)</span>
annotation<span class="token punctuation">[</span>cobra<span class="token punctuation">.</span>BashCompFilenameExt<span class="token punctuation">]</span> <span class="token operator">=</span> annotations

flag <span class="token operator">:=</span> <span class="token operator">&amp;</span>pflag<span class="token punctuation">.</span>Flag<span class="token punctuation">{</span>
    Name<span class="token punctuation">:</span>        <span class="token string">&quot;filename&quot;</span><span class="token punctuation">,</span>
    Shorthand<span class="token punctuation">:</span>   <span class="token string">&quot;f&quot;</span><span class="token punctuation">,</span>
    Usage<span class="token punctuation">:</span>       usage<span class="token punctuation">,</span>
    Value<span class="token punctuation">:</span>       value<span class="token punctuation">,</span>
    DefValue<span class="token punctuation">:</span>    value<span class="token punctuation">.</span><span class="token function">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    Annotations<span class="token punctuation">:</span> annotation<span class="token punctuation">,</span>
<span class="token punctuation">}</span>
cmd<span class="token punctuation">.</span><span class="token function">Flags</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">AddFlag</span><span class="token punctuation">(</span>flag<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>现在，当运行带有 <code>--filename</code> 或 <code>-f</code> 的命令时，将得到像下面结果：</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># kubectl create -f</span>
test/                         example/                      rpmbuild/
hello.yml                     test.json
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>因此，虽然 CWD 中还有许多其他文件，但它只显示子目录和具有有效扩展名的文件。</p><h2 id="specify-custom-flag-completion" tabindex="-1"><a class="header-anchor" href="#specify-custom-flag-completion" aria-hidden="true">#</a> Specify custom flag completion</h2><p>类似于使用 <code>cobra.BashCompFilenameExt</code> 来补全和过滤文件名。你可以使用 <code>cobra.BashCompCustom</code> 指定一个自定义标志补全函数：</p><div class="language-go ext-go line-numbers-mode"><pre class="language-go"><code>annotation <span class="token operator">:=</span> <span class="token function">make</span><span class="token punctuation">(</span><span class="token keyword">map</span><span class="token punctuation">[</span><span class="token builtin">string</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">string</span><span class="token punctuation">)</span>
annotation<span class="token punctuation">[</span>cobra<span class="token punctuation">.</span>BashCompCustom<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">string</span><span class="token punctuation">{</span><span class="token string">&quot;__kubectl_get_namespaces&quot;</span><span class="token punctuation">}</span>

flag <span class="token operator">:=</span> <span class="token operator">&amp;</span>pflag<span class="token punctuation">.</span>Flag<span class="token punctuation">{</span>
    Name<span class="token punctuation">:</span>        <span class="token string">&quot;namespace&quot;</span><span class="token punctuation">,</span>
    Usage<span class="token punctuation">:</span>       usage<span class="token punctuation">,</span>
    Annotations<span class="token punctuation">:</span> annotation<span class="token punctuation">,</span>
<span class="token punctuation">}</span>
cmd<span class="token punctuation">.</span><span class="token function">Flags</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">AddFlag</span><span class="token punctuation">(</span>flag<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>此外，在 <code>BashCompletionFunction</code> 的值中添加 <code>__handle_namespace_flag</code> 实现，例如:</p><div class="language-go ext-go line-numbers-mode"><pre class="language-go"><code><span class="token function">__kubectl_get_namespaces</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    local template
    template<span class="token operator">=</span><span class="token string">&quot;{{ range .items  }}{{ .metadata.name }} {{ end }}&quot;</span>
    local kubectl_out
    <span class="token keyword">if</span> kubectl_out<span class="token operator">=</span>$<span class="token punctuation">(</span>kubectl get <span class="token operator">-</span>o template <span class="token operator">--</span>template<span class="token operator">=</span><span class="token string">&quot;${template}&quot;</span> namespace <span class="token number">2</span><span class="token operator">&gt;</span><span class="token operator">/</span>dev<span class="token operator">/</span>null<span class="token punctuation">)</span><span class="token punctuation">;</span> then
        COMPREPLY<span class="token operator">=</span><span class="token punctuation">(</span> $<span class="token punctuation">(</span> compgen <span class="token operator">-</span>W <span class="token string">&quot;${kubectl_out}[*]&quot;</span> <span class="token operator">--</span> <span class="token string">&quot;$cur&quot;</span> <span class="token punctuation">)</span> <span class="token punctuation">)</span>
    fi
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="using-bash-aliases-for-commands" tabindex="-1"><a class="header-anchor" href="#using-bash-aliases-for-commands" aria-hidden="true">#</a> Using bash aliases for commands</h2><p>还可以为命令配置 <code>bash aliases</code>，并仍会支持补全。</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">alias</span> <span class="token assign-left variable">aliasname</span><span class="token operator">=</span>origcommand
complete -o default -F __start_origcommand aliasname

<span class="token comment"># and now when you run `aliasname` completion will make</span>
<span class="token comment"># suggestions as it did for `origcommand`.</span>

$<span class="token punctuation">)</span> aliasname <span class="token operator">&lt;</span>tab<span class="token operator">&gt;</span><span class="token operator">&lt;</span>tab<span class="token operator">&gt;</span>
completion     firstcommand   secondcommand
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><!--]--><!--[--><!--]--></div><footer class="page-meta"><!----><div class="meta-item last-updated"><span class="meta-item-label">Last Updated: </span><!----></div><!----></footer><!----><!--[--><!--]--><!----></main><!--]--></div><div class="search-page" role="search"><span class="search-close"><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 448 512" width="28" height="28" fill="currentColor"><path d="M224 416c-8.188 0-16.38-3.125-22.62-9.375l-192-192c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0L224 338.8l169.4-169.4c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25l-192 192C240.4 412.9 232.2 416 224 416z"></path></svg></span><div class="gungnir-search-box"><input placeholder="$ grep ..." autocomplete="off" spellcheck="false" value><!----></div></div><div class="menu-btn-container"><div class="menu-btn-wrapper"><div class="menu-btn"><div style="" class="menu-btn-icon"><span></span><span></span><span></span></div><div style="display:none;" class="menu-text">0</div><svg class="menu-progress"><circle class="menu-border" cx="50%" cy="50%" r="48%" style="stroke-dasharray:0% 314.15926%;"></circle></svg></div><div class="menu-btn-child-wrapper"><div class="toggle-dark-button menu-btn-child" title="toggle dark mode"><svg class="ov-icon" style="font-size:1.2em;display:none;" aria-hidden="true" width="19.2" height="19.2" viewbox="-43.52 -43.52 599.04 599.04" fill="currentColor"><path d="M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"/></svg><svg class="ov-icon" style="font-size:1.2em;display:none;" aria-hidden="true" width="19.2" height="19.2" viewbox="-43.52 -43.52 599.04 599.04" fill="currentColor"><path d="M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 00283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"/></svg><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="-43.52 -43.52 599.04 599.04" fill="currentColor"><path d="M224 96l16-32 32-16-32-16-16-32-16 32-32 16 32 16 16 32zM80 160l26.66-53.33L160 80l-53.34-26.67L80 0 53.34 53.33 0 80l53.34 26.67L80 160zm352 128l-26.66 53.33L352 368l53.34 26.67L432 448l26.66-53.33L512 368l-53.34-26.67L432 288zm70.62-193.77L417.77 9.38C411.53 3.12 403.34 0 395.15 0c-8.19 0-16.38 3.12-22.63 9.38L9.38 372.52c-12.5 12.5-12.5 32.76 0 45.25l84.85 84.85c6.25 6.25 14.44 9.37 22.62 9.37 8.19 0 16.38-3.12 22.63-9.37l363.14-363.15c12.5-12.48 12.5-32.75 0-45.24zM359.45 203.46l-50.91-50.91 86.6-86.6 50.91 50.91-86.6 86.6z"/></svg></div><div class="menu-btn-child"><svg class="ov-icon" style="font-size:1.7999999999999998em;" aria-hidden="true" width="28.799999999999997" height="28.799999999999997" viewbox="-75.52 -43.52 599.04 599.04" fill="currentColor"><path d="M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"/></svg></div><div class="menu-btn-child"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="-75.52 -43.52 599.04 599.04" fill="currentColor"><path d="M240.971 130.524l194.343 194.343c9.373 9.373 9.373 24.569 0 33.941l-22.667 22.667c-9.357 9.357-24.522 9.375-33.901.04L224 227.495 69.255 381.516c-9.379 9.335-24.544 9.317-33.901-.04l-22.667-22.667c-9.373-9.373-9.373-24.569 0-33.941L207.03 130.525c9.372-9.373 24.568-9.373 33.941-.001z"/></svg></div><!----><div class="toggle-sidebar-button menu-btn-child menu-btn-sidebar" title="toggle sidebar" aria-expanded="false" role="button" tabindex="0"><svg class="ov-icon" style="font-size:1.2em;" aria-hidden="true" width="19.2" height="19.2" viewbox="-1.6 -1.6 19.2 19.2" fill="currentColor"><path d="M14 2a1 1 0 011 1v10a1 1 0 01-1 1H2a1 1 0 01-1-1V3a1 1 0 011-1h12zM2 1a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V3a2 2 0 00-2-2H2z"/><path d="M3 4a1 1 0 011-1h2a1 1 0 011 1v8a1 1 0 01-1 1H4a1 1 0 01-1-1V4z"/></svg></div></div></div></div><!----></div><!--]--></div>
    <script type="module" src="/assets/app.80e5dc69.js" defer></script>
  </body>
</html>
